News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.CourseUtil.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
6.06 %6.06%
6.06% 4 / 66
 
CourseUtil
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 2
1.59 %1.59%
1.59% 1 / 63
 public function getCurrentSemester()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 public function createSemesterListbox($yearRange = 2, $enabledItem = 'none')
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 52


       1                 : <?php                                                                              
       2                 : /*--------------------------------------------------------------------------+      
       3                 : This file is part of eStudy.                                                       
       4                 : courses/classes/class.CourseUtil.php                                               
       5                 : - Modulgruppe:  Veranstaltung                                                      
       6                 : - Beschreibung: Sammlung statischer Methoden.                                      
       7                 : - Version:      0.2, 03/10/05                                                      
       8                 : - Autor(en):    Timo Fuchs <timo.fuchs@mni.fh-giessen.de>                          
       9                 : +---------------------------------------------------------------------------+      
      10                 : This program is free software; you can redistribute it and/or                      
      11                 : modify it under the terms of the GNU General Public License                        
      12                 : as published by the Free Software Foundation; either version 2                     
      13                 : of the License, or any later version.                                              
      14                 : +---------------------------------------------------------------------------+      
      15                 : This program is distributed in the hope that it will be useful,                    
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                     
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                      
      18                 : GNU General Public License for more details.                                       
      19                 : You should have received a copy of the GNU General Public License                  
      20                 : along with this program; if not, write to the Free Software                        
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.        
      22                 : +--------------------------------------------------------------------------*/      
      23                 :                                                                                    
      24                 : /**                                                                                
      25                 :  * In dieser Datei wird die Klasse CourseUtil implementiert.                       
      26                 :  * @package eStudy.Courses                                                         
      27                 :  * @version 0.2, 03/10/05                                                          
      28                 :  * @author  Timo Fuchs <timo.fuchs@mni.fh-giessen.de>                              
      29                 :  */                                                                                
      30                 :                                                                                    
      31               1 : global $settings;                                                                  
      32               1 : define("START_MONTH_SS", $settings["start_month_ss"]);                             
      33               1 : define("START_MONTH_WS", $settings["start_month_ws"]);                             
      34                 :                                                                                    
      35                 : /** Enthaelt Hilfsfunktion zur Veranstaltungslogistik.                             
      36                 :  *  Alle Methoden sind ohne ein Objekt zu erzeugen benutzbar.                      
      37                 :  *                                                                                 
      38                 :  *  @package eStudy.Courses                                                        
      39                 :  *  @author  Timo Fuchs <timo.fuchs@mni.fh-giessen.de>                             
      40                 :  *  @version 0.2, 03/10/05                                                         
      41                 :  */                                                                                
      42               1 : class CourseUtil {                                                                 
      43                 :                                                                                    
      44                 :     /**                                                                            
      45                 :      * Gibt das aktuelle Semester zurück.                                         
      46                 :      *                                                                             
      47                 :      * @access public                                                              
      48                 :      * @return string Semester in DB-Form (z.B. 04SS)                              
      49                 :      */                                                                            
      50                 :     function getCurrentSemester() {                                                
      51                 :         // derzeitigen Semester-Typ ermitteln                                      
      52               0 :         $currentMonth = (int) strftime("%m");  // derzeitiger Monat                
      53               0 :         if($currentMonth < START_MONTH_SS || $currentMonth >= START_MONTH_WS) {    
      54               0 :             $currentType = "WS";                                                   
      55               0 :         } else {                                                                   
      56               0 :             $currentType = "SS";                                                   
      57                 :         }                                                                          
      58               0 :         $year = (int)strftime("%y");                                               
      59               0 :         if($currentMonth < START_MONTH_SS)                                         
      60               0 :             $year = ($year - 1 + 100) % 100; // wegen Jahrhundertgrenze            
      61               0 :         if ($year < 10) $year = "0".$year;                                         
      62               0 :         return $year.$currentType;                                                 
      63                 :     }                                                                              
      64                 :                                                                                    
      65                 :     /**                                                                            
      66                 :      * Gibt eine Listbox zum auswaehlen eines Semesters per echo aus.              
      67                 :      *                                                                             
      68                 :      * @access public                                                              
      69                 :      * @static                                                                     
      70                 :      * @param integer $yearRange Zeitspanne in Jahren,                             
      71                 :      *                           die in der Listbox auswaehlbar sein soll.         
      72                 :      * @param string  $enabledItem  Semester, das ausgewaehlt sein soll            
      73                 :      *                              in der Form "WS 03/04" bzw. "SS04".            
      74                 :      * @return void                                                                
      75                 :      */                                                                            
      76                 :     function createSemesterListbox($yearRange = 2, $enabledItem = "none") {        
      77                 :                                                                                    
      78               0 :         $currentYear  = (int) strftime("%y");  // derzeitiges Jahr                 
      79               0 :         $currentMonth = (int) strftime("%m");  // derzeitiger Monat                
      80                 :                                                                                    
      81               0 :         $listbox = ""; // html-Code der Listbox                                    
      82                 :                                                                                    
      83                 :         // derzeitigen Semester-Typ ermitteln                                      
      84               0 :         if($currentMonth < START_MONTH_SS || $currentMonth >= START_MONTH_WS) {    
      85               0 :             $currentType = "WS";                                                   
      86               0 :         } else {                                                                   
      87               0 :             $currentType = "SS";                                                   
      88                 :         }                                                                          
      89                 :                                                                                    
      90                 :         // Anfangsjahr-und semester-Typ ermitteln                                  
      91               0 :         if($enabledItem === "none") {                                              
      92               0 :             $startYear = $currentYear;                                             
      93               0 :             $startType = $currentType;                                             
      94               0 :         } else {                                                                   
      95               0 :             $enabledYear = (int) substr($enabledItem, 3, 2);                       
      96               0 :             $enabledType = substr($enabledItem, 0, 2);                             
      97               0 :             if($enabledYear < $currentYear) {                                      
      98               0 :                 $startYear = $enabledYear;                                         
      99               0 :                 $startType = $enabledType;                                         
     100               0 :                 $yearRange = $yearRange + $currentYear - $enabledYear;             
     101               0 :             } elseif($enabledYear == $currentYear) {                               
     102               0 :                 $startYear = $currentYear;                                         
     103               0 :                 if($enabledType === "SS" || $currentType === "SS") {               
     104               0 :                     $startType = $currentType;                                     
     105               0 :                 } else {                                                           
     106               0 :                     $startType = "WS";                                             
     107                 :                 }                                                                  
     108               0 :             } else {                                                               
     109               0 :                 $startYear = $currentYear;                                         
     110               0 :                 $startType = $currentType;                                         
     111                 :             }                                                                      
     112                 :                                                                                    
     113                 :         }                                                                          
     114               0 :         if($startType === "WS") {                                                  
     115               0 :             $startYear--;                                                          
     116               0 :         }                                                                          
     117                 :                                                                                    
     118                 :         // Listbox konstruieren.                                                   
     119               0 :         $listbox .= "<select name='semester'>";                                    
     120               0 :         $yearCount = 0;           // zaehlt die bereits angezeigten Jahre          
     121               0 :         $tempType = $startType;   // temporaerer Semester-Typ                      
     122                 :                                                                                    
     123                 :         // Options konstruieren.                                                   
     124               0 :         while($yearCount <= $yearRange) {                                          
     125               0 :             $item  = $tempType;                                                    
     126               0 :             $item .= " ";                                                          
     127               0 :             $item .= strftime("%y", mktime(0,0,0,1,1,$startYear+$yearCount));      
     128               0 :             if($tempType === "WS") {                                               
     129               0 :                 $item .= "/";                                                      
     130               0 :                 $item .= strftime("%y", mktime(0,0,0,1,1,$startYear+$yearCount+1));
     131               0 :                 $yearCount++;                                                      
     132               0 :                 $tempType = "SS";                                                  
     133               0 :             } else {                                                               
     134               0 :                 $tempType = "WS";                                                  
     135                 :             }                                                                      
     136               0 :             $listbox .= "<option value='".$item."'";                               
     137               0 :             if($item === $enabledItem) {                                           
     138               0 :                 $listbox .= " selected='selected'";                                
     139               0 :             }                                                                      
     140               0 :             $listbox .= ">".$item."</option>";                                     
     141               0 :         }                                                                          
     142                 :                                                                                    
     143               0 :         $listbox .= "</select>";                                                   
     144                 :                                                                                    
     145                 :         // Listbox ausgeben.                                                       
     146               0 :         echo $listbox;                                                             
     147               0 :     }                                                                              
     148                 : }                                                                                  
     149                 : ?>                                                                                 

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.